{
  "$schema" : "http://json-schema.org/draft/2019-09/schema#",
  "title" : "Order Dispatch",
  "type" : "object",
  "additionalProperties" : false,
  "properties" : {
    "interfaceCategory" : {
      "type" : "string",
      "maxLength" : 20,
      "enum" : [ "Sales Order" ],
      "description" : "CMP categorization of the job."
    },
    "interfaceType" : {
      "type" : "string",
      "maxLength" : 20,
      "enum" : [ "Sales Order Dispatch" ],
      "description" : "CMP sub-categorization of the job that produces this extract file."
    },
    "version" : {
      "type" : "number",
      "minimum" : 1.2,
      "maximum" : 1.2,
      "description" : "The current version of the generic extract file. This must match the corresponding inbound file."
    },
    "transformDateTime" : {
      "type" : "string",
      "format" : "date-time",
      "description" : "Timestamp indicating when the third-party response file was transformed into the CMP generic format."
    },
    "transmitDateTime" : {
      "type" : "string",
      "format" : "date-time",
      "description" : "Timestamp indicating when the response file was received from the third-party system."
    },
    "externalFileName" : {
      "type" : "string",
      "pattern" : "^([a-zA-Z0-9._-])+$",
      "maxLength" : 20,
      "description" : "The name of the file that was received from the external system."
    },
    "recordCount" : {
      "type" : "integer",
      "minimum" : 0,
      "description" : "The number of record count kept "
    },
    "wareHouse" : {
      "$ref" : "#/definitions/WareHouse"
    },
    "orders" : {
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/Orders"
      }
    }
  },
  "required" : [ "interfaceCategory", "interfaceType", "version", "externalFileName", "recordCount", "wareHouse", "orders" ],
  "definitions" : {
    "WareHouse" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "id" : {
          "type" : "string",
          "maxLength" : 6,
          "description" : "Uniquely identifies the warehouse"
        }
      },
      "required" : [ "id" ]
    },
    "Orders" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "id" : {
          "type" : "string",
          "maxLength" : 15,
          "description" : "Uniquely identifies the order in CMP."
        },
        "externalId" : {
          "type" : "string",
          "maxLength" : 25,
          "description" : "This is the identifier of the order from the perspective of the warehouse"
        },
        "shipmentDate" : {
          "type" : "string",
          "format" : "date-time",
          "description" : "This indicates the date that the order or part order will be dispatched/shipped on"
        },
        "comment" : {
          "type" : "string",
          "maxLength" : 1000,
          "description" : "This is used to pass any comments that relate to an order. In the case of an order that has an error status, this should be used for passing information about the error"
        },
        "status" : {
          "type" : "string",
          "enum" : [ "OK", "ERROR", "REVIEW" ],
          "description" : "This indicates whether the order is ok or whether an error was returned from the database warehouse. If ERROR then the Order comment field should be populated with the error and this will be recorded as a comment"
        },
        "lines" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/Lines"
          }
        }
      },
      "required" : [ "id", "status", "lines" ]
    },
    "Lines" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "lineIdentifier" : {
          "$ref" : "#/definitions/LineIdentifier"
        },
        "resourceAttributes" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/ResourceAttributes"
          },
          "description" : "This is used when Resource Attributes are to be associated with an item that was dispatched from the warehouse."
        },
        "managedSerialNumbers" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/ManagedSerialNumbers"
          }
        }
      },
      "required" : [ "lineIdentifier" ]
    },
    "LineIdentifier" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "orderFulfilmentId" : {
          "type" : "integer",
          "minimum" : 1,
          "description" : " This uniquely identifies the line across all orders."
        },
        "uniqueOrderWarehouseLineNumber" : {
          "type" : "integer",
          "minimum" : 1,
          "description" : " This uniquely identifies the lines per warehouse within an order"
        }
      }
    },
    "ResourceAttributes" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "alias" : {
          "type" : "string",
          "maxLength" : 10,
          "description" : "This is used when Resource Attributes are to be associated with an item that was dispatched from the warehouse"
        },
        "value" : {
          "type" : "string",
          "maxLength" : 120,
          "description" : " This represents the value of an attribute e.g. a IMEI. "
        }
      },
      "required" : [ "alias", "value" ]
    },
    "ManagedSerialNumbers" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "serialNumberIdentifier" : {
          "type" : "integer",
          "maximum" : 1,
          "description" : "This is the identifier of the serial number"
        },
        "serialNumber" : {
          "type" : "string",
          "maxLength" : 25,
          "description" : "This is the actual serial number"
        }
      },
      "required" : [ "serialNumberIdentifier", "serialNumber" ]
    }
  }
}